package com.fss.product1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.product1.domain.Product1;
import com.fss.product1.service.IProduct1Service;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * 农产品产品Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/product1/product1")
public class Product1Controller extends BaseController
{
    @Autowired
    private IProduct1Service product1Service;

    /**
     * 查询农产品产品列表
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:list')")
    @GetMapping("/list")
    public TableDataInfo list(Product1 product1)
    {
        startPage();
        List<Product1> list = product1Service.selectProduct1List(product1);
        return getDataTable(list);
    }

    /**
     * 导出农产品产品列表
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:export')")
    @Log(title = "农产品产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Product1 product1)
    {
        List<Product1> list = product1Service.selectProduct1List(product1);
        ExcelUtil<Product1> util = new ExcelUtil<Product1>(Product1.class);
        util.exportExcel(response, list, "农产品产品数据");
    }

    /**
     * 获取农产品产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:query')")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(product1Service.selectProduct1ByProductId(productId));
    }

    /**
     * 新增农产品产品
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:add')")
    @Log(title = "农产品产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Product1 product1)
    {
        return toAjax(product1Service.insertProduct1(product1));
    }

    /**
     * 修改农产品产品
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:edit')")
    @Log(title = "农产品产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Product1 product1)
    {
        return toAjax(product1Service.updateProduct1(product1));
    }

    /**
     * 删除农产品产品
     */
    @PreAuthorize("@ss.hasPermi('product1:product1:remove')")
    @Log(title = "农产品产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
    public AjaxResult remove(@PathVariable Long[] productIds)
    {
        return toAjax(product1Service.deleteProduct1ByProductIds(productIds));
    }
}
